using System;
using System.Collections.Generic;
using System.Text;
namespace Test {
  class Mixer {
    static void MainX() {
      foreach(string str in Mixer.Combine("{0}-{1}-{2}-{3}","1,2,3,4","5,6","7,8,9","a,b,c,d")) {
        Console.WriteLine(str);
      }
    }
    public static string[] Combine(string format,params string[] csvargs) {
      List<List<string>> pars=new List<List<string>>();
      foreach(string str in csvargs) pars=Mix(pars,str);
      string[] ret=new string[pars.Count];
      int cnt=0;
      foreach(List<string> par in pars) {
        ret[cnt++]=string.Format(format,par.ToArray());
      }
      return ret;
    }
    static List<List<string>> Mix(List<List<string>> arr1,string csv2) {
      string[] arr2=csv2.Split(',');
      if(arr1.Count==0) {
        List<List<string>> ret0=new List<List<string>>();
        foreach(string str in arr2) {
          List<string> temp=new List<string>();
          temp.Add(str);
          ret0.Add(temp);
        }
        return ret0;
      }
      List<List<string>> ret=new List<List<string>>();
      foreach(List<string> nonchg in arr1) {
        foreach(string extelem in arr2) {
          List<string> lst=new List<string>(nonchg);
          lst.Add(extelem);
          ret.Add(lst);
        }
      }
      return ret;
    }
  }
}
